﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using QuanLyKhachSan.QuanLyKhachSanBUS;
namespace QuanLyKhachSan.UserControls
{
    public partial class TraCuu : UserControl
    {
        public TraCuu()
        {
            InitializeComponent();
        }
         
        private QuanLyKhachSanBUS.Service1SoapClient ws = new Service1SoapClient();
        private void TraCuu_Load(object sender, EventArgs e)
        {
            PhongDTO[] tb = ws.LayDanhSachPhong();
            int stt = tb.Count();
            int trucX = 50, trucY = 100;
            //Button btn = new Button();
            for (int dong = 0; dong < tb.Count(); dong++)
            {
                
                //dgvPhong.Rows.Add();
                //dgvPhong.Rows[dong].Cells[0].Value = (dong + 1).ToString();
                //dgvPhong.Rows[dong].Cells[1].Value = tb[dong].MaPhong.ToString();
                //dgvPhong.Rows[dong].Cells[2].Value = tb[dong].TenPhong.ToString();
                //dgvPhong.Rows[dong].Cells[3].Value = tb[dong].LoaiPhong.ToString();
                //dgvPhong.Rows[dong].Cells[4].Value = tb[dong].Gia.ToString();
                Button btn = new Button();
                btn.Name = tb[dong].MaPhong.ToString();
                btn.Text = tb[dong].TenPhong.ToString();
                btn.Visible = true;
                btn.Width = 70;
                btn.Height = 70;
                if (trucX > 700)
                {
                    trucX = 50;
                    trucY += 80;
                }
                btn.Location = new Point(trucX, trucY);
                btn.ForeColor=System.Drawing.Color.DarkOliveGreen;
                btn.MouseHover +=new EventHandler(btn_MouseHover);//Xu Kien hover

                btn.Margin.Left.Equals(10);
                if (tb[dong].HienTrangPhong == 1)// trong
                {
                    btn.BackColor = System.Drawing.Color.White;
                    btn.ForeColor = System.Drawing.Color.Blue;
                }
                else
                {
                    if (tb[dong].HienTrangPhong == 2)//phong thue
                    {
                        btn.BackColor = System.Drawing.Color.Red;
                        btn.ForeColor = System.Drawing.Color.White;
                    }
                    else
                    {
                        if (tb[dong].HienTrangPhong == 3)//dang duoc dat
                        {
                            btn.BackColor = System.Drawing.Color.Blue;
                            btn.ForeColor = System.Drawing.Color.White;
                        }
                        else                            // dang sua
                            btn.BackColor = System.Drawing.Color.Chocolate;
                    }
                }
                this.Controls.Add(btn); //them Button vao
                trucX += 80; //trucY += 50;
            }

        }
        private void btn_MouseHover(object sender, EventArgs e)
        {
            
        }


    }
}
